using System.Data;
using System.Data.OracleClient;
namespace WPFExcelReport
{

    public partial class VICC_MENUDEF
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "YCC":
                default:
                    #region====ICC_MENUDEF======
                    dwReturn["MANDANT"] = "00";
                    dwReturn["ROWNID"] = "0";
                    dwReturn["COMPANY"] = app.company;
                    dwReturn["USERID"] = "        ";
                    dwReturn["PROCESS"] = "MENU";
                    dwReturn["MENUITEM"] = "           ";
                    dwReturn["MENUID"] = "020107";
                    dwReturn["FATHER"] = " ";
                    dwReturn["HEADER"] = "      ";
                    dwReturn["TAG"] = "                    ";
                    dwReturn["ICON"] = @"Resources\Images\16x16\new_project.png";
                    dwReturn["LARGEICON"] = @"Resources\Images\32x32\new_project.png";
                    dwReturn["JOB"] = "";
                    dwReturn["TIMER"] = "";
                    dwReturn["SCHEDULETYPE"] = "";
                    dwReturn["FREQUENCY"] = "";
                    dwReturn["TIME"] = "";

                    #endregion
                    break;
            }
        }
        public void InsertICC_MENUDEF(DataRow dwData, string ITXDBVERSION = "50.24")
        {

            or1 = OracleDB.CreateCommand(); 
            or1.CommandText = "INSERT INTO ICC_MENUDEF ( MANDANT,ROWNID,COMPANY,USERID,PROCESS,MENUITEM,MENUID,FATHER,HEADER,TAG,ICON,LARGEICON,JOB,TIMER,SCHEDULETYPE,FREQUENCY,TIME)"
            + " VALUES (:MANDANT:,:ROWNID:,:COMPANY:,:USERID:,:PROCESS:,:MENUITEM:,:MENUID:,:FATHER:,:HEADER:,:TAG:,:ICON:,:LARGEICON:,:JOB:,:TIMER:,:SCHEDULETYPE:,:FREQUENCY:,:TIME:)";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            Connect2Proxy(or1);
        }
        public void DeleteICC_MENUDEF(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "DELETE FROM ICC_MENUDEF ";
                    break;
                case 1:
                    or1.CommandText = "DELETE FROM ICC_MENUDEF  WHERE PROCESS='HIDDEN'";
                    break;
                case 2:
                    or1.CommandText = "DELETE FROM ICC_MENUDEF  WHERE ROWNID=:ROWNID:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                default:
                    break;
            }

            Connect2Proxy(or1);
        }

        public DataSet QueryICC_MENUDEF(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ICC_MENUDEF WHERE MANDANT=:MANDANT:  AND ROWNID=:ROWNID:"; ;
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM ICC_MENUDEF WHERE MANDANT=:MANDANT:  AND USERID=:USERID:"; ;
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM ICC_MENUDEF WHERE MANDANT=:MANDANT: AND COMPANY=:COMPANY:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case 9999:
                    or1.CommandText = "SELECT * FROM ICC_MENUDEF";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                default:
                    break;
            }
            SResult = Connect2Proxy(or1);

            SResult.Tables[0].TableName = "ICC_MENUDEF";

            return SResult;
        }
        public void UpdateICC_MENUDEF(DataRow dwData, string ITXDBVERSION = "50.24")
        {

            or1 = OracleDB.CreateCommand();

            or1.CommandText = "UPDATE ICC_MENUDEF SET MANDANT=:MANDANT:,ROWNID=:ROWNID:,COMPANY=:COMPANY:,USERID=:USERID:,PROCESS=:PROCESS:,MENUITEM=:MENUITEM:,MENUID=:MENUID:,FATHER=:FATHER:,HEADER=:HEADER:,TAG=:TAG:,ICON=:ICON:,LARGEICON=:LARGEICON:,JOB=:JOB:,TIMER=:TIMER:,SCHEDULETYPE=:SCHEDULETYPE:,FREQUENCY=:FREQUENCY:,TIME=:TIME:"
                + " WHERE ROWNID=:ROWNID:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
    }
}
